#include "widget.h"
#include "ui_widget.h"
#include <QPushButton>
#include <QRect>
#include <QDebug>
Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);
//    QIcon icon = QIcon(R"(C:\Users\zyk\Desktop\warrior\1.jpg)");
//      QIcon icon= QIcon("C:\\Users\\zyk\\Desktop\\warrior\\1.jpg");
//          QIcon icon= QIcon("C:/Users/zyk/Desktop/warrior/1.jpg");
    QIcon icon= QIcon(":/1.jpg");
    this->setWindowIcon(icon);

//        //只有最顶层的控件Widget才能修改标题
//    this->setWindowTitle("Widget类设置窗口标题");
//    ui->pushButton_up->setWindowTitle("按钮设置标题");
}

Widget::~Widget()
{
    delete ui;
}

//void Widget::on_pushButton_clicked()
//{
//    //当点击按钮时，触发该信号槽
//    if( ui->pushButton_2->isEnabled())//当为使用状态时改成禁用
//    {
//        ui->pushButton_2->setEnabled(false);
//    }
//    else{//反之
//        ui->pushButton_2->setEnabled(true);
//    }
//}



void Widget::on_pushButton_up_clicked()
{
    QRect rect = ui->pushButton_vessel->geometry();
    qDebug() << rect.y();
    ui->pushButton_vessel->setGeometry(rect.x(),rect.y() - 5,rect.width(),rect.height());
}

void Widget::on_pushButton_left_clicked()
{
    QRect rect = ui->pushButton_vessel->geometry();
    qDebug() << rect.x();
    ui->pushButton_vessel->setGeometry(rect.x() - 5,rect.y(),rect.width(),rect.height());
}

void Widget::on_pushButton_down_clicked()
{
    QRect rect = ui->pushButton_vessel->geometry();
    qDebug() << rect.y();
    ui->pushButton_vessel->setGeometry(rect.x(),rect.y() + 5,rect.width(),rect.height());
}

void Widget::on_pushButton_right_clicked()
{
    QRect rect = ui->pushButton_vessel->geometry();
    qDebug() << rect.y();
    ui->pushButton_vessel->setGeometry(rect.x()+ 5,rect.y(),rect.width(),rect.height());
}

void Widget::on_pushButton_plus_clicked()
{
    float opacity = this->windowOpacity();
    this->setWindowOpacity(opacity + 0.1);
}

void Widget::on_pushButton_sub_clicked()
{
    float opacity = this->windowOpacity();
    this->setWindowOpacity(opacity - 0.1);
}
